<template>
  <div class="home">
    <!-- 多图轮播 -->
    <el-carousel :interval="4000" type="card" height="200px">
      <el-carousel-item v-for="item in images" :key="item">
        <img :src="item" style="width: 100%; height: 100%;">
      </el-carousel-item>
    </el-carousel>

    <!-- 文章列表 -->
    <div class="article-list">
      <el-card class="article-item" v-for="(article, index) in articles" :key="index" style="margin-bottom: 20px;">
        <template #header>
          <div class="article-header">
            <span>{{ article.title }}</span>
            <small style="float: right; padding: 3px 0">{{ article.date }}</small>
          </div>
        </template>
        <div class="article-content">
          <p>{{ article.content }}</p>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script>
// 使用 import 静态导入图片资源
import image1 from '@/assets/image1.png';
import image2 from '@/assets/image2.png';
import image3 from '@/assets/image3.png';

export default {
  name: 'HomeView',
  data () {
    return {
      images: [
        // 使用静态导入方式引入图片资源
        image1,
        image2,
        image3
      ],
      articles: [
        {
          title: 'Article 1',
          content: 'Summary of Article 1...',
          date: '2025-07-08'
        },
        {
          title: 'Article 2',
          content: 'Summary of Article 2...',
          date: '2025-07-08'
        },
        {
          title: 'Article 3',
          content: 'Summary of Article 3...',
          date: '2025-07-08'
        }
      ]
    }
  }
}
</script>

<style scoped>
/* 轮播图样式 */
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
}

/* 文章列表样式 */
.article-list {
  margin-top: 20px;
}

.article-item {
  border: 1px solid #ccc;
  padding: 10px;
  margin-bottom: 10px;
}

.article-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.article-content {
  text-align: left;
}
